/* -*- C++ -*- */
/**
*  @file ORB_Objects.h
*
*  $Id: ORB_Objects.h 81424 2008-04-24 14:02:21Z johnnyw $
*
*  @author Pradeep Gore <pradeep@oomworks.com>
*
*
*/

#ifndef TAO_Notify_ORB_OBJECTS_H
#define TAO_Notify_ORB_OBJECTS_H
#include /**/ "ace/pre.h"

#include "tao/RTCORBA/RTCORBA.h"
#include "tao/PortableServer/PortableServer.h"
#include "orbsvcs/NotifyExtC.h"
#include "orbsvcs/CosNamingC.h"

#include "dllmain.h"
//#include "../cppx.core/fuString.h"
//using cppx::fuString;

/**
* @class ORB_Objects
*
* @brief Handy Objects that we keep asking the ORB for.
*
*/
class CPPXCORBA_API ORB_Objects
{
    //= Public Data
public:
    CORBA::ORB_var                  root_orb_;
    PortableServer::POA_var         root_poa_;

    RTCORBA::RTORB_var              rt_orb_;
    PortableServer::POA_var         rt_poa_;

    //RTCORBA::Current_var            rt_current_;
    //PortableServer::Current_var     poa_current_;

    //CosNaming::NamingContextExt_var naming_;
    CosNaming::NamingContext_var    naming_;

public:
    /// Constructor
    ORB_Objects (void);
    ORB_Objects (CORBA::ORB_var& orb, const char* name_server = NULL);

    /// Destructor
    ~ORB_Objects();

    static std::string _check_naming(std::string naming);

    /// Check if the default name server is ok.
    operator bool(void){
        return !CORBA::is_nil(naming_.in());
    }

    /// Resolves all the references.
    void init (CORBA::ORB_var& orb, const char* name_server = NULL);

    /// Bind and unbind the name
    int rebind_name( std::string name, CORBA::Object_ptr );
    int unbind_name( std::string name );

    /// Resolve the name
    CORBA::Object_ptr                              resolve(const char *name,const char* name_server = NULL);
    CosNotifyChannelAdmin::EventChannelFactory_ptr resolve_notify_factory(const char* name_server = NULL);
    CosNotifyChannelAdmin::EventChannel_ptr        resolve_notify_channel(const char* name_server = NULL,int ec_id = 0);

    /// Create the objects
    CosNotifyChannelAdmin::EventChannel_ptr  create_event_channel(int ec_thread_count_);
    CosNotifyChannelAdmin::SupplierAdmin_ptr create_supplier_admin(CosNotifyChannelAdmin::EventChannel_ptr ec);
    CosNotifyChannelAdmin::ConsumerAdmin_ptr create_consumer_admin(CosNotifyChannelAdmin::EventChannel_ptr ec);
};

#include /**/ "ace/post.h"
#endif /* TAO_Notify_ORB_OBJECTS_H */
